#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;

int n, m;
int a[N];
int head[N];
int ver[N << 1], Next[N << 1], tot;
void add(int u, int v) {
  ++tot;
  ver[tot] = v;
  Next[tot] = head[u];
  head[u] = tot;
}
int dep[N], sz[N], fa[N], son[N], top[N];
int pos[N], b[N], num;
void dfs(int u, int fu) {
  dep[u] = dep[fu] + 1;
  sz[u] = 1;
  fa[u] = fu;
  for (int i = head[u]; i; i = Next[i]) {
    int v = ver[i];
    if (v == fu) continue;
    dfs(v, u);
    sz[u] += sz[v];
    if (sz[v] > sz[son[u]]) son[u] = v;
  }
}
void dfs2(int u, int fu, int t) {
  top[u] = t;
  pos[u] = ++num;
  b[num] = a[u];
  if (!son[u]) return;
  dfs2(son[u], u, t);
  for (int i = head[u]; i; i = Next[i]) {
    int v = ver[i];
    if (v == fu || v == son[u]) continue;
    dfs2(v, u, v);
  }
}

int ch[N << 5][2], cnt[N << 5];
int root[N];
int newnode(int p) {
  static int top = 0;
  ++top;
  ch[top][0] = ch[p][0];
  ch[top][1] = ch[p][1];
  cnt[top] = cnt[p];
  return top;
}
int insert(int p, int x) {
  p = newnode(p);
  int res = p;
  per(i, 29, 0) {
    int c = (x >> i) & 1;
    ch[p][c] = newnode(ch[p][c]);
    p = ch[p][c];
    cnt[p]++;
  }
  return res;
}
int search(int p1, int p2, int x) {
  int res = 0;
  per(i, 29, 0) {
    int c = (x >> i) & 1;
    int d = cnt[ch[p1][c]] - cnt[ch[p2][c]];
    if (!d) c ^= 1;
    p1 = ch[p1][c], p2 = ch[p2][c];
    res |= c << i;
  }
  return res;
}
void build() { rep(i, 1, n) root[i] = insert(root[i - 1], b[i]); }
int query_subtree(int u, int x) {
  int L = pos[u] - 1, R = L + sz[u];
  int y = search(root[R], root[L], ~x);
  return y ^ x;
}
int query(int u, int v, int z) {
  int res = 0;
  while (top[u] != top[v]) {
    if (dep[top[u]] < dep[top[v]]) swap(u, v);
    int L = pos[top[u]] - 1, R = pos[u];
    int x = search(root[R], root[L], ~z);
    res = max(res, x ^ z);
    u = fa[top[u]];
  }
  if (dep[u] > dep[v]) swap(u, v);
  int L = pos[u] - 1, R = pos[v];
  int x = search(root[R], root[L], ~z);
  res = max(res, x ^ z);
  return res;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  rep(i, 1, n) cin >> a[i];
  rep(i, 2, n) {
    int u, v;
    cin >> u >> v;
    add(u, v), add(v, u);
  }
  dfs(1, 0);
  dfs2(1, 0, 1);
  build();
  while (m--) {
    int op, x, y, z;
    cin >> op;
    if (op == 1) {
      cin >> x >> y;
      cout << query_subtree(x, y) << endl;
    } else {
      cin >> x >> y >> z;
      cout << query(x, y, z) << endl;
    }
  }
  return 0;
}